<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title></title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				$('.select-chosen').chosen();
				$('.select-chosen').chosen();
                $('.date-picker').datepicker();
				ligerTable = $('#table').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/${route}/getList',
					delayLoad:false,
					columns:[
					    {display:'编号',name:'id',id:'id',align:'center'},
						{display:'路线名称',name:'fromTo',id:'fromTo',align:'center'},
						{display:'所属公司',name:'companyName',id:'companyName',align:'center',minWidth:200},
						{display:'出发城市',name:'startCity',id:'startCity',align:'center',minWidth:200},
						{display:'到达城市',name:'endCity',id:'endCity',align:'center',minWidth:200},
                        {display:'基础里程(km)',name:'mileage',id:'mileage',align:'center',minWidth:100},
                        {display:'价格(元)',name:'price',id:'price',align:'center',minWidth:100},
						{display:'单价(元/公里)',name:'kmPrice',id:'kmPrice',align:'center',minWidth:110},
						{display:'平台提成',name:'chargeRatio',id:'chargeRatio',align:'center',minWidth:80},
						{display:'分公司提成',name:'subChargeRatio',id:'subChargeRatio',align:'center',minWidth:110},
						{
							display:'操作时间',
							name:'updateTime',
							id:'updateTime',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.updateTime > 0){
						 			return formatDate(row.updateTime * 1000);
						 		}
						 		return '-';
							}
						},
						{display:'操作人',name:'operator',id:'operator',align:'center',minWidth:80},
						{
							display:'是否启用',
							name:'enabled',
							id:'enabled',
							align:'center',
							minWidth:150,
							render:function(row){
						 		if(row.enabled){
						 			return '是';
						 		}
						 		return '否';
							}
						}
					],
					onDblClickRow: function (data, rowindex, rowobj){
						layer.open({
							title:'${module}',
							type:2,
							maxmin:false,
							area: ['100%', '100%'],
							content:'${base}/${route}/view/'+data.id
						});
					}
				});

				function reload(){
                    if(ligerTable){
                        var companyId = $('#companyId').val();
                        var startCity = $('#txtStartCity').val();
                        var endCity = $('#txtEndCity').val();
                        var searchKey = $('#txtSearchKey').val();
                        ligerTable.setParm('companyId',companyId);
                        ligerTable.setParm('startCity',startCity);
                        ligerTable.setParm('endCity',endCity);
                        ligerTable.setParm('searchKey',searchKey);
                        ligerTable.reload();
                    }
                }
                $('#btnSearch').click(function(){
                    reload();
                })
				
				$('#btnEdit').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.roadId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var roadId = row.id;
			        	var url='${base}/${route}/edit/'+roadId;
			            changePage(url);
			    	}
				});
				$('#btnRemove').click(function(){
					if(ligerTable){
			    		var row = ligerTable.getSelectedRow();
			    		if(!row || row.roadId < 1){
							layer.msg('请选择行')
			    			return;
			    		}
			    		var roadId = row.id;
			    		layer.confirm('确定要删除吗？',function(){
			    			$.ajax({
			            		url:'${base}/${route}/remove/'+roadId,
			            		type:'POST',
			            		data:{},
			            		dataType:'json',
			            		success:function(rst){
			            			layer.alert(rst.message);
			            			if(rst.status=='OK' && ligerTable != null ){
			            				ligerTable.reload();
			            			}
			            		}
			            	});	
			    		});
			    	}
				});
			});
		//-->
		</script>
	</head>
	<body class="$configs["skinName"]">
		<#include "common/breadcrumb.ftl">
        <div class="widget-box">
			<div class="widget-header widget-header-flat">
				<h5 class="lighter">
					<i class="fa fa-search"></i>
					${module}查询
				</h5>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="row">
						<div class="col-sm-3 input-group">
							<span class="input-group-addon">路线所属公司</span>
							<select id="companyId" class="width-100">
								<option value="">全部</option>
								<#if companyList?exists && companyList?size gt 0>
								<#list companyList as item >
								<option value="${item.companyId}">${item.ownerName}</option>
								</#list>
								</#if>
							</select>
						</div>
					</div>
					<div class="space-4"></div>
					<div class="row">
						<div class="col-sm-10">
							<div class="input-group">
							    <span class="input-group-addon">出发城市</span>
                                <input id="txtStartCity" type="text" class="form-control search-query" placeholder="请输入出发城市" />
                            	<span class="input-group-addon">到达城市</span>
                                <input id="txtEndCity" type="text" class="form-control search-query" placeholder="请输入出发城市" />

								<span class="input-group-addon">关键字</span>
								<input id="txtSearchKey" type="text" class="form-control search-query" placeholder="请输关键字搜索" />
								<span class="input-group-btn">
									<button id="btnSearch" type="button" class="btn btn-purple btn-sm">
										查询
										<i class="icon-search icon-on-right bigger-110"></i>
									</button>
								</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="widget-box">
			<div class="widget-header">
				<h5 class="lighter">
					<i class="icon-table"></i>
					${module}列表
				</h5>
				<!--非查询者有该操作-->
				<#if user?exists && viewerRole?exists && user.roleId != viewerRole>
				<div class="widget-toolbar">
					<button id="btnEdit" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-check-square-o"></i>编辑
					</button>
					<button id="btnRemove" type="button" class="btn btn-primary btn-xs">
						<i class="fa fa-trash-o"></i>删除
					</button>
				</div>
				</#if>
			</div>

			<div class="widget-body">
				<div id="table"><div>
			</div>
		</div>
	</body>
</html>